package com.tianhui.consignortwofei.mvp.ui.activity;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.fgs.common.CommonPresenter;
import com.fgs.common.CommonView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.base.BaseActivity;
import com.tianhui.consignortwofei.base.BaseFragment;
import com.tianhui.consignortwofei.manager.SharedPreferenceManager;
import com.xuexiang.xqrcode.XQRCode;

import butterknife.BindView;

/**
 * @author fgs
 * @date 2020/4/28
 * @description
 **/
public class MyTwoCodeActivity extends BaseActivity {

    @BindView(R.id.tv_twocode)
    ImageView tv_twocode;


    @Override
    public int getLayoutId() {
        return R.layout.activity_my_twocode;
    }

    @Override
    public CommonPresenter createPresenter() {
        return null;
    }

    @Override
    public CommonView createView() {
        return null;
    }

    @Override
    public void init() {
        setTitle("我的二维码");


        String consignorId = SharedPreferenceManager.getInstance().getConsignorId();
        String roleId = SharedPreferenceManager.getInstance().getRoleId();
        String consignorName = SharedPreferenceManager.getInstance().getConsignorName();
        String text = "货主|"+consignorId + "|" + roleId + "|" + consignorName;
        Bitmap qrCodeWithLogo = XQRCode.createQRCodeWithLogo(text, null);
        tv_twocode.setImageBitmap(qrCodeWithLogo);

    }

    @Override
    public BaseFragment createFragment() {
        return null;
    }

//    @OnClick(R.id.activity_about_versionUpdateSettingItemView)
//    public void versionUpdate() {
//        updateCheck();
//    }



//
//    @OnClick(R.id.activity_about_downloadTextView)
//    public void download() {
//        String url = AppConfig.apkUrl;
//        Uri uri = Uri.parse(url);
//        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        startActivity(intent);
//    }


    public  void makeCode(String[] args) {
        int width = 300;
        int height = 300;
        String format = "png";
        String content = "www.guoqick.cn";

//        HashMap hints = new HashMap();
//        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
//        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
//        hints.put(EncodeHintType.MARGIN, 2);
//
//        try {
//            BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
//            Path file = new File("E:/code/img.png").toPath();
//            MatrixToImageWriter.writeToPath(bitMatrix,format,file);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

    }


}
